
package com.trydofor.id.doer.shell;

/**
 * the outcome of command
 * 
 * @author : Shi Rongjiu (www.trydofor.com)
 */
public class Outcome {
    
    private final String output;
    private final String errput;
    private final int    status;
    
    /**
     * constructor
     * 
     * @param rts the return status, 0 means successful.
     * @param out the out message
     * @param err the err message
     */
    public Outcome(int rts, String out, String err) {
        this.status = rts;
        this.output = out;
        this.errput = err;
    }
    
    /**
     * @return the out
     */
    public String outPut() {
        return output;
    }
    
    /**
     * @return the err
     */
    public String errPut() {
        return errput;
    }
    
    /**
     * @return the status
     */
    public int status() {
        return status;
    }
    
    /**
     * {@inheritDoc}
     */
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("[status]:").append(status);
        if (output != null) {
            sb.append(" [output]:").append(output);
        }
        if (errput != null) {
            sb.append(" [errput]:").append(errput);
        }
        return sb.toString();
    }
}
